import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 服务器地址
    // serverResource: '/api/', // 本地开发时打开
    serverResource: '', // 发布时打开
    user: null,
    sidebar: {
      opened: true,
      withoutAnimation: false
    },
    fixedHeader: false,
    sidebarLogo: false,
    avatar: './assets/admin.jpg',
    device: 'desktop'
  },
  mutations: { // 属性的修改只能通过mutations来进行，不懂看看文档
		pushUser (state, user) {
			state.user = user
		},
		removeUser (state) {
			state.user = null
    },
    toggleDevice (state, device) {
      state.device = device
    },
    toggleSideBar(state){
      state.sidebar.opened = !state.sidebar.opened
      state.sidebar.withoutAnimation = false
    },
    closeSideBar(state, {withoutAnimation}) {
      state.sidebar.withoutAnimation = withoutAnimation
    }
  }
})
